package com.ymttest.database.sqlwapper;

import java.util.List;

import com.ymt.core.tool.Logger;
import com.ymt.database.SqlManager;
import com.ymttest.database.model.YmtProductDescription;
import com.ymttest.database.model.YmtProductsI;
import com.ymttest.utils.EnvSetup;

/************************************************************************************
 * @File name : YmtProductDescriptionWapper.java
 * @Author : zhouyi
 * @Date : 2015年5月19日
 * @Copyright : 洋码头
 ************************************************************************************/
public class YmtProductDescriptionWapper {
	SqlManager manage;

	public YmtProductDescriptionWapper() {
		manage = new SqlManager("intpro");
	}

	/**
	 * insert 一条YmtProductDescription记录
	 * 
	 * @param record
	 *            YmtProductDescription
	 * @return
	 * @throws InterruptedException
	 */
	public int insertYmtProductDescription(YmtProductDescription record) {
		int i = manage.insert("com.ymttest.database.mapping.YmtProductDescriptionMapper.insert", record);
		manage.commit();
		// manage.close();
		return i;
	}

	public String selectProductDescriptionByProductId(String sProductId) throws InterruptedException {
	    @SuppressWarnings("unchecked")
	    List<YmtProductDescription>  sYmtProductDescription = manage.getSelectResults(
	            "com.ymttest.database.mapping.YmtProductDescriptionMapper.selectProductDescriptionByProductId", sProductId);
	    		String mdescription = sYmtProductDescription.get(0).getMdescription();
	    		if (mdescription == null) {
					return "null";
				}
//	    manage.commit();
	    return mdescription;
	}
	
	
	public static void main(String args[]) {
	    try {
	         
	    	YmtProductDescriptionWapper ymtProductDescriptionWapper = new YmtProductDescriptionWapper();	                 
	        String rm = ymtProductDescriptionWapper.selectProductDescriptionByProductId("6bede0f6-7641-4474-9ba9-d83adead529d");
	        Logger.debug(rm);
	         
	    } catch (InterruptedException e) {
	        e.printStackTrace();
	    }
	}
	
	/**
	 * 关闭数据库连接
	 */
	public void close() {
		manage.close();
	}

	@Override
	protected void finalize() throws Throwable {
		this.close();
		manage = null;
		super.finalize();
	}


}
